{include file="public/header" /}

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <fieldset id="searchFieldset_currentTableRenderId" class="table-search-fieldset">
                        <legend>条件搜索</legend>
                        <form class="layui-form layui-form-pane form-search">
                            <div class="layui-form-item layui-inline">
                                <label class="layui-form-label">申请人</label>
                                <div class="layui-input-inline">
                                    <select name="user_id" lay-search>
                                        <option value="">选择申请人</option>
                                        {foreach $user as $v}
                                        <option value="{$v.id}" {if !empty(input('get.user_id')) && input('get.user_id')==$v.id}selected{/if}>{$v.account|default=''}（{$v.remark|default=''}）</option>
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item layui-inline">
                                <label class="layui-form-label">申请店铺</label>
                                <div class="layui-input-inline">
                                    <select name="businessid" lay-search>
                                        <option value="">选择申请店铺</option>
                                        {foreach $business as $v}
                                        <option value="{$v.id}" {if !empty(input('get.businessid')) && input('get.businessid')==$v.id}selected{/if}>{$v.title|default=''}（{$v.address|default=''}）</option>
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item layui-inline">
                                <label class="layui-form-label">申请状态</label>
                                <div class="layui-input-inline">
                                    <select name="status">
                                        <option value="">申请状态</option>
                                        <option value="1" {if !empty(input('get.status')) && input('get.status')==1}selected{/if}>营业中</option>
                                        <option value="2" {if !empty(input('get.status')) && input('get.status')==2}selected{/if}>预备开业</option>
                                        <option value="3" {if !empty(input('get.status')) && input('get.status')==3}selected{/if}>可选店面</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item layui-inline">
                                <label class="layui-form-label">审核状态</label>
                                <div class="layui-input-inline">
                                    <select name="czstatus">
                                        <option value="">申请状态</option>
                                        <option value="1" {if !empty(input('get.czstatus')) && input('get.czstatus')==1}selected{/if}>待审核</option>
                                        <option value="2" {if !empty(input('get.czstatus')) && input('get.czstatus')==2}selected{/if}>同意</option>
                                        <option value="3" {if !empty(input('get.czstatus')) && input('get.czstatus')==3}selected{/if}>驳回</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item layui-inline">
                                <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="sreach">搜索</button>
                            </div>
                        </form>
                    </fieldset>
                </div>
                <div class="layui-card-header">
                    <!--<button type="button" class="layui-btn layui-btn-sm" id="test1">-->
                    <!--     商家导入-->
                    <!--</button>-->
                    <!--<button class="layui-btn layui-bg-cyan layui-btn-sm" onclick="open_add('添加','shoplist_edit')"><i-->
                    <!--        class="layui-icon">&#xe654;</i>添加</button>&nbsp;-->
                    共有数据：<strong id="count">{$list->total()}</strong> 条
                </div>
                <div class="layui-table-body layui-table-main">
                    <table class="layui-table layui-form">
                        <thead>
                            <tr>
                                <th>
                                    <div class="layui-table-cell">ID</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">申请人信息</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">店铺信息</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">申请店铺状态</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">营业时间</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">审核状态</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">操作</div>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            {foreach $list as $v}
                            <tr>
                                <td>
                                    <div class="layui-table-cell">{$v.id|default=''}</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.user.account|default=''}({$v.user.remark|default='无'})</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">店铺ID:{$v.shop.id}</div>
                                    <div class="layui-table-cell">店铺名称:{$v.shop.title}</div>
                                    <div class="layui-table-cell">店铺地址:{$v.shop.address}</div>
                                    <div class="layui-table-cell">原收银机编码:{$v.shop.mobile|default='---'}</div>
                                    <div class="layui-table-cell">更改银机编码:{$v.mobile|default='---'}</div>
                                </td>
                                <td>
                                    {if $v.status == 1}<div class="layui-table-cell">营业中</div>{/if}
                                    {if $v.status == 2}<div class="layui-table-cell">预备开业</div>{/if}
                                    {if $v.status == 3}<div class="layui-table-cell">可选店面</div>{/if}
                                </td>
                                <td>
                                    <div class="layui-table-cell">
                                        {$v.times|default='无'}
                                    </div>
                                </td>
                                <td>
                                    {if $v.czstatus == 1}<div class="layui-table-cell">待审核</div>{/if}
                                    {if $v.czstatus == 2}<div class="layui-table-cell">同意</div>{/if}
                                    {if $v.czstatus == 3}<div class="layui-table-cell">取消</div>{/if}
                                </td>
                                <td class="td-manage">
                                    <div class="layui-table-cell">
                                        {if $v.czstatus == 1}
                                        <a title="同意" onclick="open_status(this, '/shop/opendstr', {$v.id}, 2)"
                                            href="javascript:;" class="layui-btn layui-btn-sm">
                                            同意
                                        </a>
                                        <a title="取消" onclick="open_status(this, '/shop/opendstr', {$v.id}, 3)"
                                            href="javascript:;" class="layui-btn layui-btn-danger layui-btn-sm">
                                            取消
                                        </a>
                                        {/if}
                                        {if $v.czstatus == 2}<div class="layui-table-cell">同意</div>{/if}
                                        {if $v.czstatus == 3}<div class="layui-table-cell">取消</div>{/if}
                                    </div>
                                </td>

                            </tr>
                            {/foreach}

                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page">
                        {$list->render()|raw}
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>
</body>
{include file="public/footer"}
<script>
    layui.use('upload', function () {
        var $ = layui.jquery
        var upload = layui.upload;
        //执行实例
        var uploadInst = upload.render({
            elem: '#test1' //绑定元素
            , accept: 'file'
            , url: '/shop/import_batch_send' //上传接口
            , before: function (obj) { //obj参数包含的信息，跟 choose回调完全一致，可参见上文。
                layer.load(); //上传loading
            },done: function (res) {
                layer.closeAll('loading'); //关闭loading
                //如果上传失败
                if (res.status == 0) {
                    str = '导入完成，失败个数' + res.data.length + '<br/>';
                    $.each(res.data, function (i, obj) {
                        str += '<div>第' + obj.key + '行:' + obj.msg + '</div>';
                    });
                    layer.open({
                        type: 0,
                        content: str,
                        yes: function () {
                            location.reload();
                        }
                    });
                    return false;
                } else {
                    layer.msg(res.msg, { icon: 2, time: 1000 });
                    return false;
                }
            }
            , error: function () {
                layer.closeAll('loading'); //关闭loading
                layer.msg('请求失败请重试', { icon: 2, time: 1000 });
                return false;

            }
        });
    });
</script>
<script>
    function money_edit(title, url, id) {
        layer.prompt({
            formType: 0,
            value: 0,
            title: title,
        }, function (value, index, elem) {
            $.ajax({
                type: 'post',
                url: url,
                data: { id: id, money: value },
                success: function (res) {
                    if (res.code == 0) {
                        layer.msg(res.msg, { icon: 6, time: 1000 }, function () {
                            layer.close(index);
                            // 获得frame索引
                            location.reload();
                        });
                    } else {
                        layer.msg(res.msg, { icon: 2, time: 1000 });
                    }
                }
            });
            return false;

        });
    }
    layui.use(['form', 'upload'], function () {
        var $ = layui.jquery
            , form = layui.form
            , layer = layui.layer;
    });
</script>
<script>
    layer.photos({
        photos: '#layer-photos'
        , anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
    });
</script>